//
//  VEHmoeOtherTableViewCell.m
//  VET
//
//  Created by BlueWind on 2018/8/31.
//  Copyright © 2018年 BlueWind. All rights reserved.
//

#import "VEHmoeOtherTableViewCell.h"

@implementation VEHmoeOtherTableViewCell

{
    
    UILabel *_summary; /**<描述*/
    
    UIImageView *_newsImage; /**<图片*/
    
    UILabel *_timeLabel;
    
    UILabel *_lookNum;
    
    UILabel *_author;
    
}

/** 返回循环利用的cell */
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self= [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self loadDefaultSetting];
    }
    return self;
}

/** 加载默认UI元素和需要的数据 */
- (void)loadDefaultSetting {
    
    
    
    _newsImage = [UIImageView new];
    [self.contentView addSubview:_newsImage];
    [_newsImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(15);
        make.right.equalTo(self.contentView).offset(-15);
        make.size.mas_equalTo(CGSizeMake(110, 70));
    }];
    _newsImage.contentMode = UIViewContentModeScaleAspectFill;
    _newsImage.clipsToBounds = YES;
    _newsImage.image = [UIImage imageNamed:@"First_PlaceHolder"];
    
    _summary = [UILabel new];
    [self.contentView addSubview:_summary];
    [_summary mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self->_newsImage);
        make.left.equalTo(self.contentView).offset(15);
        make.right.equalTo(self->_newsImage.mas_left).offset(-8);
    }];
    _summary.font = [UIFont systemFontOfSize:16];
    _summary.numberOfLines = 2;
    _summary.text = @"雅加达亚运会田径比赛完美收官，中国军团表现的不错，比如苏炳添打破亚运会纪录拿到100米飞人大战的金牌，确实很振奋人心，期待中国田径队在2020年东京奥运会上有更好的表现。";
    
    
    _timeLabel = [UILabel new];
    [self.contentView addSubview:_timeLabel];
    [_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self->_newsImage.mas_bottom);
        make.left.equalTo(self->_summary);
    }];
    _timeLabel.textColor = [UIColor lightGrayColor];
    _timeLabel.text = @"一小时钱";
    _timeLabel.font = [UIFont systemFontOfSize:14];
    
    _lookNum = [UILabel new];
    [self.contentView addSubview:_lookNum];
    [_lookNum mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self->_newsImage.mas_bottom);
        make.left.equalTo(self->_timeLabel.mas_right).offset(8);
    }];
    _lookNum.textColor = [UIColor lightGrayColor];
//    _lookNum.text = @"20089浏览";
    _lookNum.font = [UIFont systemFontOfSize:14];
    
    _author = [UILabel new];
    [self.contentView addSubview:_author];
    [_author mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self->_newsImage.mas_bottom);
        make.left.equalTo(self->_lookNum.mas_right).offset(8);
    }];
    _author.textColor = [UIColor lightGrayColor];
    _author.text = @"";
    _author.font = [UIFont systemFontOfSize:14];
    
    UIView *line = [UIView new];
    [self.contentView addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.contentView);
        make.left.equalTo(self.contentView);
        make.right.equalTo(self.contentView);
        make.height.mas_equalTo(0.5);
    }];
    line.backgroundColor = [UIColor colorWithHexString:kLineViewBgColor];
    
}

- (void)setModel:(VEFastModel *)model {
    _model = model;
    _summary.text = model.ARTICLETITLE;
    _author.text = model.ARTICLETYPE;
    _timeLabel.text = [NSDate dateDescriptionWithTargetDate:model.RELEASETIME andTargetDateFormat:@"yyyy/MM/dd HH:mm:ss"];
    
    [_newsImage setImageWithUrlString:model.ARTICLEMSG palceHolderImage:[UIImage imageNamed:@"First_PlaceHolder"]];
    
}

@end
